package leetcode.code0995;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int minKBitFlips(int[] nums, int k) {
		int len = nums.length;
		int[] h = new int[len + 1];
		int ans = 0, op = 0;
		for (int i = 0; i < nums.length; i++) {
			int num = nums[i];
			op += h[i];
			num = (op & 1) == 0 ? num : num ^ 1;
			if (num == 1) {
				continue;
			}
			if (len - i < k) {
				return -1;
			}
			ans += 1;
			op += 1;
			h[i + k] -= 1;
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		String a = "abc";
		String b = "bcd";
		System.out.println(a.equals(b));
	}

}
